#ifndef _LOCAL_PARTITION_H
#define _LOCAL_PARTITION_H

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <bitset>

#include "../../../../utils/CacheLRU.hpp"
#include "constants.h"


class LocalPartition {
     private:
         uint32_t _size;
         uint32_t _victimPolicy;
         uint32_t _count;
         uint32_t _victimIndex;
         uint32_t *_pages;
         std::bitset <128> _L0filter;
         std::bitset <128> _NRU;
         std::bitset <128> _NRUmodified;
         uint32_t *_LRU;


         int getVictimIndex(uint32_t page);
         void updateVictimPolicy(uint32_t page,uint32_t index);
         void insertVictimInformation(uint32_t page,uint32_t index);
    public:
         LocalPartition(uint32_t size,uint32_t victimPolicy);
        ~LocalPartition();
        void reset();
        bool find(uint32_t page);
        bool insert(uint32_t page,uint32_t & victim);
        void read(uint32_t page,bool remote);
        bool write(uint32_t page,bool remote);
        bool remove(uint32_t page);
        void resetL0Filter();
        inline uint32_t getSize()          const  { return _size; }
        inline uint32_t getCount()         const  { return _count; }
        inline uint32_t getVictimPolicy()  const  { return _victimPolicy; }
};

#endif
